package core.util;

import java.io.Serializable;
import java.net.InetAddress;

/**
 * IP, port Pair in local group membership table.
 * 
 * @author bh349
 * 
 */
public class IpPortPair implements Serializable
{
    /**
	 * 
	 */
	private static final long serialVersionUID = -4821544839529919711L;

	private InetAddress ip;

    private int port;

    public IpPortPair( InetAddress ip, int port ) {
        this.ip = ip;
        this.port = port;
    }

    public InetAddress getIp() {
        return ip;
    }

    public int getPort() {
        return port;
    }
    
    @Override
    public boolean equals(Object ob){
    	IpPortPair otherPair;
    	try{
    		otherPair = (IpPortPair)ob;
    	}catch(Exception e){
    		return false;
    	}
    	return otherPair.ip.equals(ip) && otherPair.port == port;
    }
    
    
    @Override
    public int hashCode(){
    	return ip.hashCode() + port;
    }
    
}